#pragma once
#include "SnRender.h"
#include "base/SnImage.h"
#include "base/shader.h"
#include <memory>
#include <vector>
namespace Sivin {
  class YUVPBORender : public SnRender {
    struct SnVertex {
      GLfloat postion[3];
      GLfloat texCoord[2];
    };

  public:
    explicit YUVPBORender();
    ~YUVPBORender();

  public:
    void onGLInit() override;
    void onRender() override;

  private:
    void initVAO();
    void initYUVPixelBuffer();

  private:
    GLuint mVAO;

    GLuint mYPboId{0};
    GLuint mUPboId{0};
    GLuint mVPboId{0};

    GLuint mYTextureId{0};
    GLuint mUTextureId{0};
    GLuint mVTextureId{0};


    std::unique_ptr<Shader> mShader{nullptr};
    std::vector<SnVertex> mVertexData;
    std::vector<GLuint> mElementIndexArray;
  };
}// namespace Sivin